#ifndef _E_DEBUG_H_
#define _E_DEBUG_H_

#include "EColor.h"

#include "eH.h"
namespace engine
{

#define eDEBUG_RENDER

//------------------------------------------------------------
class EDebugDrawable
{
  bool      m_bDebugStarted;
  EColor    m_cColor;
public :
  EDebugDrawable();
  virtual ~EDebugDrawable();

  virtual inline void startDebug      ();
  virtual inline void endDebug        ();
  virtual void        drawDebug       () const = 0;
  inline bool         isDebugStarted  () const { return m_bDebugStarted; }
  inline void         setDebugColor   (const EColor& color) { m_cColor = color;}
  inline void         setDebugColor   (float fR, float fG, float fB, float fA = 1.f) { m_cColor = EColor(fR, fG, fB, fA);}
  inline const EColor& getDebugColor  () const { return m_cColor; }
};

//------------------------------------------------------------
class EDebugRenderer
{
  typedef vector<EDebugDrawable*> EDebugDrawableVector;
  SceneManager*             m_pOgreSceneManager;
  EDebugDrawableVector      m_vecDrawables;
  bool                      m_bDebugStarted;
public:
  EDebugRenderer();
  void                  startDebug    ();
  void                  endDebug      ();
  void                  drawDebug     ();
  inline bool           isDebugStarted() const { return m_bDebugStarted; }
  inline void           setCurrentOgreSceneManager    ( SceneManager* pManager) { m_pOgreSceneManager = pManager;}
  /** \return returns a reference of the current scene manager instead
   of a pointer because, most of the time, coders won't test if the return value
   is NULL or not for just some debug things */
  SceneManager&         getCurrentOgreSceneManager    () const;

  /** Used to tell the debug renderer to manage the life cycle of the debug renderable */
  void                  addDrawable(EDebugDrawable& drawable);

  /** Remove the drawable from the global debug lifecycle management */
  void                  removeDrawable(const EDebugDrawable& drawable);
};

extern EDebugRenderer g_debugRenderer;

} // end namespace

#endif